package zouran.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.multipart.MultipartFile;
import zouran.entity.Admin;
import zouran.entity.News;
import zouran.entity.User;
import zouran.mapper.AdminMapper;
import zouran.mapper.NewsMapper;
import zouran.mapper.UserMapper;
import zouran.service.AdminService;
import zouran.service.NewsService;
import zouran.service.UserService;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @Author: zouran
 * @Description:
 * @Date: Created in 2022 2022/12/4 11:04
 **/
@SpringBootTest
@CrossOrigin
@RunWith(SpringRunner.class)
public class TestController {
    @Autowired
    AdminService adminService;
    @Autowired
    NewsService newsService;
    @Autowired
    UserMapper userMapper;

    @Test
    public void test() {
//         System.out.println(adminService.select_user("10086"));
//         System.out.println(userMapper.selectById("10010"));
//         System.out.println(newsService.select_byAuthor("王维"));
//        QueryWrapper<User> wrapper = new QueryWrapper<>();
//        wrapper.select().likeRight("sex","男");//前者为默认返回类，可指定返回数据
//        List<Map<String, Object>> maps = userMapper.selectMaps(wrapper);
//        maps.forEach(System.out::println);
        // User user=new User("10002","小明","123456","男","null",0);
        //System.out.println(userMapper.insert(user));
//          User user=userMapper.selectById("10001");
//          user.setSex("女");
//          userMapper.updateById(user);
//        System.out.println(userMapper.selectById("10001"));
//        Page<User> page =new Page<>(2,3);
//        userMapper.selectPage(page,null);
//        page.getRecords().forEach(System.out::println);
//        //获取总数
//        page.getTotal();
//        System.out.println(userMapper.deleteById(user.getUserPhone()));
//        System.out.println(userMapper.insert(user));
//        user.setUserEmail("qqqq");
//        System.out.println(userMapper.updateById(user));
//        System.out.println(userMapper.selectList(null));
//          newsService.select_byTitle("木兰词");
//          newsService.getAllNews();
        //System.out.println(adminService.select_user("10001"));
//        News news=new News();
//        news.setNewsAuthor("A");
//        news.setNewsTitle("A");
//        DateTimeFormatter dateTimeFormatter=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//        LocalTime time=new LocalTime();
//        System.out.println(LocalDateTime.parse(dateTimeFormatter.format(time)));
//          System.out.println(userMapper.selectById("100"));
    }

}
